package com.example.lib_base.net

import com.example.lib_base.Res
import com.example.lib_base.entity.*
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {

    @GET(Const.HOME_URL)
    suspend fun getHome(@Query("userId")userId:Int):Res<HomeEntityResult>

    @POST(Const.USER_URL)
    suspend fun login(@Query("username")username:String,@Query("password")password:String):Res<UserEntityResult>

    @POST(Const.REGISTER_URL)
    suspend fun register(@Query("username")username:String,@Query("password")password:String):Res<RegisterEntitResult>

    @GET(Const.PARK_URL)
    suspend fun getParksByType(@Path("spaceType")spaceType:String):Res<ParkBean>

    @GET(Const.ANNOUNCEMENT_URL)
    suspend fun getAnnouncement(@Query("userId")userId:Int):Res<AnnouncementBean>


    @GET("/api/parking-spaces/status/{spaceStatus}")
    suspend fun getParksByStatus(@Path("spaceStatus")spaceStatus:String):Res<ParkBean>

    @GET("/api/parking-spaces/area/{areaId}")
    suspend fun getParksByAreaId(@Path("areaId")areaId:Int):Res<ParkBean>

    @GET(Const.CAR_URL)
    suspend fun car(@Path("areaId")areaId:Int):Res<CarBeanItem>

    @POST(Const.PARK_ADD_URL)
    suspend fun addPark(@Body body: RequestBody):Res<ParkBean>

    @GET(Const.REPAIR_URL)
    suspend fun repair():Res<RepairBean>

    @GET(Const.PERAIRBYUNAME_URL)
    suspend fun getRepairByUname(@Query("repairName")repairName:String):Res<RepairBean>

    @GET(Const.GETPAIRBYNO_URL)
    suspend fun getPairByNo(@Path("orderNumber")orderNumber:String):Res<RepairBeanItem>

    @GET(Const.GETPARIRBYID_URL)
    suspend fun getPairById(@Path("id")id:Int):Res<RepairBeanItem>

    @PUT(Const.UPDATEPAIR_URL)
    suspend fun updateRepair(@Path("id")id:Int,@Body body: RequestBody):Res<RepairBeanItem>

    @PUT(Const.UPDATEPARK_URL)
    suspend fun updatePark(@Path("id")id:Int,@Body body: RequestBody):Res<ParkBeanItem>

    @POST(Const.ADDREPAIR_URL)
    suspend fun addRepair(@Body body: RequestBody):Res<RepairBeanItem>

    @DELETE(Const.DELETEREPAIR_URL)
    suspend fun deleteRepair(@Path("id")id:Int):Res<String>

    @GET(Const.VISIT_URL)
    suspend fun visit():Res<VisitBean>

    @GET(Const.VIS_STATUS_URL)
    suspend fun visStatus(@Path("status")status:String):Res<VisitBean>

    @GET(Const.VISITBYID_URL)
    suspend fun getVisitById(@Path("id")id:Int):Res<VisitBeanItem>

    @POST(Const.VISIT_ADD_URL)
    suspend fun visitAdd(@Body body: RequestBody):Res<VisitBean>

    @PATCH(Const.APPROVEVISTIT_URL)
    suspend fun approveVisit(@Path("id")id:Int):Res<VisitBeanItem>

    @PATCH(Const.REJECTVISIT_URL)
    suspend fun rejectVisit(@Path("id")id:Int):Res<VisitBeanItem>

    @DELETE(Const.VISIT_DELETE_URL)
    suspend fun deleteVisit(@Path("id")id:Int):Res<Boolean>

    @GET(Const.SIGN_LIST_URL)
    suspend fun signList(@Path("userId")userId:Int):Res<SignBean>



    @POST(Const.SIGN_URL)
    suspend fun sign(@Body body: RequestBody):Res<SignBeanItem>

    @GET("/api/employees")
    suspend fun getEmp():Res<EmpBean>

    @GET("/api/departments")
    suspend fun getDepart():Res<DepartBean>

    @POST("/api/employees")
    suspend fun addEmp(@Body body: RequestBody):Res<EmpBeanItem>

    @GET("/api/properties")
    suspend fun getHouse():Res<HouseBean>

    @GET("/api/properties/region/{regionId}")
    suspend fun getHourseById(@Path("regionId")regionId:Int):Res<HouseBean>

    @PATCH("/api/properties/rent/{id}")
    suspend fun rentHouse(@Path("id")id:Int,@Query("rentDate")rentDate:String):Res<HouseBeanItem>

    @PATCH("/api/properties/unrent/{id}")
    suspend fun unrentHouse(@Path("id")id:Int):Res<HouseBeanItem>

    //点位管理
    @GET("/api/patrol-points")
    suspend fun getPoints():Res<PointsBeanItem>

    @POST("/api/patrol-points")
    suspend fun addPoints(@Body body: RequestBody):Res<PointsBeanItemItem>

    @DELETE("/api/patrol-points/{id}")
    suspend fun deletePoints(@Path("id")id:Int):Res<Boolean>

    @GET("/api/patrol-points/{id}")
    suspend fun detailPoints(@Path("id")id:Int):Res<PointsBeanItemItem>

    @GET("/api/patrol-points/{id}")
    suspend fun getPointById(@Path("id")id:Int):Res<PointsBeanItemItem>

    @GET("/api/patrol-tasks")
    suspend fun getPatrolTasks():Res<PatrolTaskBean>

    @GET("/api/inspection-orders")
    suspend fun getOrders():Res<RepairBean>

    @GET("/api/patrol-tasks/by-status/{status}")
    suspend fun order(@Path("status")status:String):Res<PatrolTaskBean>

    //设备管理
    @GET("/api/devices")
    suspend fun getDevices():Res<DevicesBean>

    @POST("/api/devices")
    suspend fun addDevices(@Body body: RequestBody):Res<DevicesBeanItem>

    @GET("/api/devices/search/name")
    suspend fun devicesSearch(@Query("keyword")keyword:String):Res<DevicesBean>

    //商家入住
    @GET("/api/merchant-applications")
    suspend fun getMerchant():Res<MerchatBean>

    @GET("/api/merchant-applications/{id}")
    suspend fun getMerchantById(@Path("id")id:Int):Res<MerchatBeanItem>

    @PATCH("/api/merchant-applications/approve/{id}")
    suspend fun approve(@Path("id")id:Int):Res<MerchatBeanItem>

    @PATCH("/api/merchant-applications/reject/{id}")
    suspend fun reject(@Path("id")id:Int):Res<MerchatBeanItem>

    @POST("/api/merchant-applications")
    suspend fun merchantAdd(@Body body: RequestBody):Res<MerchatBeanItem>


    //新闻园区
    @GET("/api/news")
    suspend fun getNews():Res<NewsBean>

    @POST("/api/news")
    suspend fun addNews(@Body body: RequestBody):Res<NewsBeanItem>

    @GET("/api/news/search")
    suspend fun newsSearch(@Query("keyword")keyword:String):Res<NewsBean>

    @DELETE("/api/news/{id}")
    suspend fun newsDelete(@Path("id")id:Int):Res<Boolean>

    //巡逻管理
    @GET("/api/patrol-tasks")
    suspend fun getPatrol():Res<PatrolBean>

    @POST("/api/patrol-tasks")
    suspend fun addPatrol(@Body body: RequestBody):Res<PatrolBeanItem>


    //月卡
    @GET("/memberships/{userId}")
    suspend fun getMember(@Path("userId")userId:Int):MemberBean

    @PUT("/memberships/{userId}/upgrade")
    suspend fun upgradeMember( @Path("userId")userId:Int,@Query("newMembershipLevel")newMembershipLevel:String
   ):MemberBean


    //账单
    @GET("/api/bills/payer/{payerId}")
    suspend fun getPayer(@Path("payerId")payerId:Int):Res<PayerBean>

    @GET("/api/bills/{id}")
    suspend fun payerDetail(@Path("id")id:Int):Res<PayerBeanItem>

    @POST("/api/bills")
    suspend fun payerAdd(@Body body: RequestBody):Res<PayerBeanItem>

    @GET("/api/patrol-tasks/{id}")
    suspend fun getTaskById(@Path("id")id:Int):Res<PatrolTaskBeanItem>

}